package com.neiquan.neiquandemo.test;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.TextView;

import com.neiquan.neiquandemo.R;
import com.pizidea.imagepicker.AndroidImagePicker;
import com.pizidea.imagepicker.bean.ImageItem;
import com.pizidea.imagepicker.image.ImagePreviewActivity;

import net.neiquan.applibrary.barlibrary.ImmersionBar;
import net.neiquan.applibrary.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * 作者 ： 邓勇军
 * 时间 ： 2016/12/29.
 * version:1.0
 */
public class OneFragment extends BaseFragment implements View.OnClickListener {
    @InjectView(R.id.standard)
    Button standard;
    @InjectView(R.id.mTiTleTv)
    TextView mTiTleTv;

    @Override
    public int getRootViewId() {
        return R.layout.home_layout;
    }

    @Override
    public void setViews() {
        ImmersionBar.setTitleBar(getActivity(), mTiTleTv);
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.standard})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.standard:
//                ArrayList<String> urls = new ArrayList<>();
//                urls.add("http://www.zhlzw.com/UploadFiles/Article_UploadFiles/201204/20120412123914329.jpg");
//                urls.add("http://www.zhlzw.com/UploadFiles/Article_UploadFiles/201204/20120412123929822.jpg");
//                urls.add("http://pic1.16pic.com/00/10/80/16pic_1080912_b.jpg");
//                final ArrayList<ImageItem> mImageList = new ArrayList<>();
//                mImageList.clear();
//                if (urls != null && urls.size() > 0) {
//                    for (int i = 0; i < urls.size(); i++) {
//                        ImageItem imageItem = new ImageItem();
//                        imageItem.setPath(urls.get(i));
//                        mImageList.add(imageItem);
//                    }
//                }
//                Intent intent = new Intent();
//                intent.putExtra(AndroidImagePicker.KEY_PIC_SELECTED_POSITION, 0);
//                intent.setClass(getActivity(), ImagePreviewActivity.class);
//                intent.putParcelableArrayListExtra(ImagePreviewActivity.IMAGEURL, mImageList);
//                startActivity(intent);
                startActivity(new Intent(getActivity(), ImmersionBarActivity.class));
                break;
        }
    }

    //弹出菜单，x轴或者y轴，mIvMain为管理按钮，view为传入的x或y轴的view
//    private void inMenuAnimY(final View view) {
//        view.setVisibility(View.VISIBLE);
//        int[] mainLocation = new int[2];
//        mIvMain.getLocationOnScreen(mainLocation);
//        int[] viewLocation = new int[2];
//        view.getLocationOnScreen(viewLocation);
//        int y = mainLocation[1] - viewLocation[1];
//        TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, y, 0);
//        ScaleAnimation scaleAnimation = new ScaleAnimation(0.1f, 1f, 0.1f, 1f, view.getWidth() / 2, view.getHeight() / 2);
//        AnimationSet animationSet = new AnimationSet(false);
//        animationSet.addAnimation(scaleAnimation);
//        animationSet.addAnimation(translateAnimation);
//        animationSet.setDuration(300);
//        view.startAnimation(animationSet);
//        view.startAnimation(animationSet);
//    }
//
//    private void inMenuAnimX(final View view) {
//        view.setVisibility(View.VISIBLE);
//        int[] mainLocation = new int[2];
//        mIvMain.getLocationOnScreen(mainLocation);
//        int[] viewLocation = new int[2];
//        view.getLocationOnScreen(viewLocation);
//        int x = mainLocation[0] - viewLocation[0];
//        TranslateAnimation translateAnimation = new TranslateAnimation(x, 0, 0, 0);
//        ScaleAnimation scaleAnimation = new ScaleAnimation(0.1f, 1f, 0.1f, 1f, view.getWidth() / 2, view.getHeight() / 2);
//        AnimationSet animationSet = new AnimationSet(false);
//        animationSet.addAnimation(scaleAnimation);
//        animationSet.addAnimation(translateAnimation);
//        animationSet.setDuration(300);
//        view.startAnimation(animationSet);
//        view.startAnimation(animationSet);
//    }
//
//    private void outMenuAnimY(final View view) {
//        int[] mainLocation = new int[2];
//        mIvMain.getLocationOnScreen(mainLocation);
//        int[] viewLocation = new int[2];
//        view.getLocationOnScreen(viewLocation);
//        int y = mainLocation[1] - viewLocation[1];
//        TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 0, y);
//        ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0.1f, 1f, 0.1f, view.getWidth() / 2, view.getHeight() / 2);
//        AnimationSet animationSet = new AnimationSet(false);
//        animationSet.addAnimation(scaleAnimation);
//        animationSet.addAnimation(translateAnimation);
//        animationSet.setDuration(300);
//
//        view.startAnimation(animationSet);
//        animationSet.setAnimationListener(new Animation.AnimationListener() {
//            @Override
//            public void onAnimationStart(Animation animation) {
//            }
//
//            @Override
//            public void onAnimationEnd(Animation animation) {
//                view.setVisibility(View.INVISIBLE);
//                view.clearAnimation();
//            }
//
//            @Override
//            public void onAnimationRepeat(Animation animation) {
//            }
//        });
//    }
//
//    private void outMenuAnimX(final View view) {
//        int[] mainLocation = new int[2];
//        mIvMain.getLocationOnScreen(mainLocation);
//        int[] viewLocation = new int[2];
//        view.getLocationOnScreen(viewLocation);
//        int x = mainLocation[0] - viewLocation[0];
//        TranslateAnimation translateAnimation = new TranslateAnimation(0, x, 0, 0);
//        ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0.1f, 1f, 0.1f, view.getWidth() / 2, view.getHeight() / 2);
//        AnimationSet animationSet = new AnimationSet(false);
//        animationSet.addAnimation(scaleAnimation);
//        animationSet.addAnimation(translateAnimation);
//        animationSet.setDuration(300);
//
//        view.startAnimation(animationSet);
//        animationSet.setAnimationListener(new Animation.AnimationListener() {
//            @Override
//            public void onAnimationStart(Animation animation) {
//            }
//
//            @Override
//            public void onAnimationEnd(Animation animation) {
//                view.setVisibility(View.INVISIBLE);
//                view.clearAnimation();
//            }
//
//            @Override
//            public void onAnimationRepeat(Animation animation) {
//            }
//        });
//    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.inject(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }
}

